//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
.uk-layui-form
    form.layui-form.uk-form(method='post', action='/setting/tag/update.html')
        input(type='hidden', name='id', value=tag.id)
        input(type='hidden', name='tagtype', value=tagtype)
        input#initialColor(type='hidden', value=tag.color)
        .layui-form-item
            label.layui-form-label 标签：
            .layui-input-inline
                input.layui-input(type='text', name='tag', required, value=tag.tag, lay-verify='required', placeholder='请输入标签', autocomplete='off')
        .layui-form-item(style='margin-top:20px;')
            label.layui-form-label 背景颜色：
            .layui-input-inline.ukefu-im-theme(style='width: 350px;')
                .item-cnt.ukefu-im-ping-color(style='display: block;')
                    input#color(type='hidden', name='color', value=tag.color)
                    .ukefu-im-item.theme1(data-class="theme1", data-value="1", class= (tag.color == 1 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
                    .ukefu-im-item.theme2(data-class="theme2", data-value="2", class= (tag.color == 2 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
                    .ukefu-im-item.theme3(data-class="theme3", data-value="3", class= (tag.color == 3 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
                    .ukefu-im-item.theme4(data-class="theme4", data-value="4", class= (tag.color == 4 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
                    .ukefu-im-item.theme5(data-class="theme5", data-value="5", class= (tag.color == 5 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
                    .ukefu-im-item.theme6(data-class="theme6", data-value="6", class= (tag.color == 6 ? "ukefu-im-checked" : ""))
                        i.layui-icon.ukefu-im-check &#xe618;
        .layui-form-button
            .layui-button-block
                button.layui-btn(lay-submit, lay-filter='formDemo') 立即提交
                button.layui-btn.layui-btn-original#reset(type='reset') 重置
script.
    layui.use('form', function () {
        var form = layui.form();
        form.render(); //更新全部
        form.verify({
            repass: function (value) {
                if (value != $('#password').val()) {
                    return '两次输入的密码不一致，请确认';
                }
            }
        });
    });
    $(document).ready(function () {
        $('.ukefu-im-ping-color .ukefu-im-item')
            .click(
                function () {
                    var theme = $(this).attr(
                        'data-class');
                    $('.ukefu-im-ping-color .ukefu-im-item')
                        .removeClass(
                            'ukefu-im-checked');
                    $(this).addClass('ukefu-im-checked');
                    $('#color').val($(this).attr('data-value'));
                });
    });

    $("#reset").click(function () {
        var num = $("#initialColor").val()
        $('.ukefu-im-ping-color .ukefu-im-item')
            .removeClass(
                'ukefu-im-checked');
        $(".theme" + num).addClass('ukefu-im-checked');
        $('#color').val(num)
    })

